<ui:composition template="templates/template2.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="titulo">Relação de Representantes Legais</ui:define>

	<ui:define name="conteudo">
		<p:panel header="Relação de Representantes Legais" footer="HelperSE">
			<h:form>
				<p:messages id="messages" showDetail="false" autoUpdate="true"
					closable="true" />
				<p:dataTable var="RepresentaLegalParam"
					value="#{RepresentaLegalBean.RepresentaLegais}" id="listaRepresentaLegal"
					rows="10" paginator="true"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink}
                          {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15" widgetVar="RepresentaLegalTable"
					emptyMessage="Nenhum dado foi encontrado!"
					filteredValue="#{RepresentaLegalBean.filteredRepresentaLegais}">
					<p:column headerText="Código">
						<h:outputText value="#{RepresentaLegalParam.id}" />
					</p:column>
					<p:column headerText="Nome" sortBy="#{RepresentaLegalParam.nome}"
						filterBy="#{RepresentaLegalParam.nome}" footerText="Nome"
						filterMatchMode="exact">
						<f:facet name="filter">
							<p:selectOneMenu onchange="PF('RepresentaLegalTable').filter()">
								<f:selectItems value="#{RepresentaLegalParam.nome}" />
							</p:selectOneMenu>
						</f:facet>
						<h:outputText value="#{RepresentaLegalParam.nome}" />
					</p:column>
					<p:column headerText="Cpf">
						<a href="cpf:${RepresentaLegalParam.cpf}"> <h:outputText
								value="#{RepresentaLegalParam.cpf}" />
						</a>
					</p:column>
					<p:column headerText="Email">
						<a href="email:${RepresentaLegalParam.email}"> <h:outputText
								value="#{RepresentaLegalParam.email}" />
						</a>
					</p:column>
					<p:column headerText="Telefone">
						<a href="telefone:${RepresentaLegalParam.telefone}"> <h:outputText
								value="#{RepresentaLegalParam.telefone}" />
						</a>
					</p:column>
					
					<p:column headerText="Editar">
						<p:commandButton value="[Editar]"
							action="/editaRepresentaLegal.xhtml?faces-redirect=true">
							<f:setPropertyActionListener
								target="#{RepresentaLegalBean.RepresentaLegal}"
								value="#{RepresentaLegalParam}"></f:setPropertyActionListener>
						</p:commandButton>
					</p:column>
					<p:column headerText="Apagar">
						<p:commandButton value="[Apagar]"
							actionListener="#{RepresentaLegalBean.apagarRepresentaLegal(RepresentaLegalParam)}"
							update="listaRepresentaLegal">
							<p:confirm header="Exclusão de Representantes Legais"
								icon="ui-icon-alert"
								message="Deseja realmente excluir este representante legal?">
							</p:confirm>
						</p:commandButton>
					</p:column>
				</p:dataTable>
				<p:confirmDialog global="true" showEffect="fade"
					hideEffect="explode">
					<p:commandButton value="Sim" type="button"
						styleClass="ui-confirmdialog-yes" icon="ui-icon-check"></p:commandButton>
					<p:commandButton value="Não" type="button"
						styleClass="ui-confirmdialog-no" icon="ui-icon-close"></p:commandButton>
				</p:confirmDialog>
			</h:form>
		</p:panel>
	</ui:define>
</ui:composition>